--纠纷起诉
local jiufenqisu = fk.CreateSkill {
    name = "mcdh_jiufenqisu",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

jiufenqisu:addEffect('active',{
    prompt = "#mcdh_jiufenqisu-active",
    anim_type = "control",
    can_use = function(self, player)
        return player:usedSkillTimes(self.name, Player.HistoryPhase) == 0
    end,
    card_filter = Util.FalseFunc,
    target_num = 2,
    target_filter = function(self, player,to_select, selected)
        local room = Fk:currentRoom()
        if #selected >= 2 then return false end
        return #selected == 0 or selected[1]:canPindian(to_select)
    end,
    on_use = function(self, room, effect)
        local from =effect.tos[1]
        local to = effect.tos[2]
        local pindian = from:pindian({ to }, self.name)
        room:delay(500)
        if pindian.results[to].winner then
            if from == pindian.results[to].winner then
                room:obtainCard(from, pindian.results[to].toCard, true, fk.ReasonJustMove, from, self.name)
                if to:getHandcardNum() > 0 then
                    local cid = room:askForCardChosen(from, to, "h", self.name)
                    room:obtainCard(from, cid, false, fk.ReasonPrey, from, self.name)
                end
            else
                local fromCard = pindian.results[to.id].fromCard or pindian.fromCard
                room:obtainCard(to, fromCard, true, fk.ReasonJustMove, to, self.name)
                if from:getHandcardNum() > 0 then
                    local cid = room:askForCardChosen(to, from, "h", self.name)
                    room:obtainCard(to, cid, false, fk.ReasonPrey, to, self.name)
                end
            end
        end
    end
})

Fk:loadTranslationTable {
    ["mcdh_jiufenqisu"] = "起诉",
    [":mcdh_jiufenqisu"] = "『纠纷起诉』<br>出牌阶段限一次，你可以令一名角色与另一名角色拼点。赢的角色获得没赢角色的拼点牌和一张手牌。",
    ["#mcdh_jiufenqisu-active"] = "纠纷起诉:令两名角色拼点，赢家拿牌",
}

return jiufenqisu